package savet.entidades.atributos;

import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Temporal;
import savet.util.DataUtil;

/**
 *
 * @author Rafael
 */
@Entity
@Table
public class AtributoData extends Atributo {

    @Temporal(javax.persistence.TemporalType.DATE)
    private Date data;

    /**
     * Texto para indicar valor na celula
     */
    private String text = "";

    public AtributoData() {
    }

    public AtributoData(Date data) {
        this.data = data;
    }

    public AtributoData(int estado, Date data) {
        super(estado);
        this.data = data;
    }

    public Date getData() {
        return data;
    }

    public void setData(Date data) {
        this.data = data;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final AtributoData other = (AtributoData) obj;
        
        return DataUtil.equals(this.data, other.data, DataUtil.FORMATO_MES_ANO);

    }

    @Override
    public int hashCode() {
        int hash = 3 + super.hashCode();
        if (this.data != null) {
            String dataMesAno = DataUtil.converteDateToString(data, DataUtil.FORMATO_MES_ANO);
            hash = 47 * hash + dataMesAno.hashCode();
        } else {
            hash = 47 * hash + 0;
        }
        return hash;
    }
    
}
